import java.util.Arrays;

public class XuanZePaiXv {
    public static void main(String[] args) {
        int[] arr = {5, 2, 3, 1};
        for (int j = 0; j < arr.length - 1; j++) {
            int minIndex =j ;//优化
            for (int i = j + 1; i < arr.length; i++) {
                if (arr[j] > arr[i]) {
//                    int temp = arr[j];
//                    arr[j] = arr[i];
//                    arr[i] = temp;
                    minIndex=i;
                }
            }
            if(minIndex!=j){
                int temp=arr[j];
                arr[j]=arr[minIndex];
                arr[minIndex]=temp;
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
